package com.salton123.revenue

import android.app.Activity
import android.app.Application
import com.salton123.provider.IRevenueProvider
import java.util.*

/**
 * Time:2022/2/25 3:44 下午
 * Author:
 * Description:
 */
object RevenueFacade {
    private lateinit var application: Application
    private val counter: Counter = Counter()
    private val timer: Timer = Timer()
    private val adProviders: LinkedList<IRevenueProvider> = LinkedList()

    fun init(application: Application, vararg provider: IRevenueProvider) {
        this.application = application
        adProviders.addAll(provider)
    }

    internal fun app(): Application {
        return application
    }

    fun logic(activity: Activity) {
        if (timer.countDown() || counter.add()) {
            show(activity)
        }
    }

    fun show(activity: Activity) {
        RewardAdsDisplayer(adProviders).apply {
            show(activity)
        }
    }
}